@import (once) "../../include/vars";
@import (once) "../../include/mixins";

:root {
    --tabs-border-radius: 6px;
    --tabs-border-radius-pills: 16px;
    --tabs-background: var(--default-background);
    --tabs-color: var(--default-color);
    --tabs-hamburger-background: transparent;
    --tabs-hamburger-color: #000000;
    --tabs-item-background: var(--default-background);
    --tabs-item-color: var(--default-color);
    --tabs-item-background-hover: #f5f8fe;
    --tabs-item-color-hover: var(--default-color);
    --tabs-item-background-active: #eaeaea;
    --tabs-item-color-active: var(--default-color);
    --tabs-item-marker: var(--color-primary);
    --tabs-item-marker-height: 2px;
    --tabs-item-icon-background: #ffffff;
    --tabs-item-icon-color: #000000;
}

.dark-side {
    --tabs-background: var(--default-background);
    --tabs-color: var(--default-color);
    --tabs-hamburger-background: transparent;
    --tabs-hamburger-color: #ffffff;
    --tabs-item-background: var(--default-background);
    --tabs-item-color: var(--default-color);
    --tabs-item-background-hover: #26282e;
    --tabs-item-color-hover: var(--default-color);
    --tabs-item-background-active: #4a4d51;
    --tabs-item-color-active: var(--default-color);
    --tabs-item-marker: var(--color-primary);
    --tabs-item-icon-background: #343637;
    --tabs-item-icon-color: #ffffff;
}

.tabs {
    position: relative;
    border: 1px solid var(--border-color);
    background-color: var(--tabs-background);
    color: var(--tabs-color);

    .hamburger, .expand-title {
        cursor: pointer;
    }

    .hamburger {
        position: absolute;
        top: 2px;
        right: 10px;
        display: block;
        background: var(--tabs-hamburger-background);
    }

    .expand-title {
        display: block;
        padding: .65rem 1rem 0;
        background-color: inherit;
        color: inherit;
        text-decoration: none;
    }
}

.tabs > ul.tabs-list {
    .reset-list();
    display: flex;
    flex-direction: column;
    justify-content: inherit;
    width: 100%;
    position: relative;
    padding: 10px 4px 0;

    .collapse();
}

.tabs > ul.tabs-list {
    & > li, a {
        position: relative;
    }

    & > li {
        display: block;
        background-color: var(--tabs-item-background);
        color: var(--tabs-item-color);
        margin: 0;
        &:last-child {
            margin-bottom: 4px;
        }
    }
    
    &:not(.expand) > li {
        border-top-left-radius: var(--tabs-border-radius);
        border-top-right-radius: var(--tabs-border-radius);
    }
    
    &.expand > li {
        border-radius: var(--tabs-border-radius)!important;
    }

    & > li > a {
        padding: 4px 1rem;
        background-color: inherit;
        color: inherit;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: flex-start;

        &:hover {
            text-decoration: none;
        }

        & > [class*=mif-] {
            margin: 0 4px;
        }
        
        .icon {
            width: 20px;
            height: 20px;
            line-height: 20px;
            font-size: 14px;
            text-align: center;
            margin-right: 8px;
            display: inline-flex;
            
            * {
                width: 100%;
                height: 100%;
                object-fit: cover;
                display: flex;
                align-items: center;
                justify-content: center;
            }
        }
        
        &.dropdown-toggle {
            &::before {
                border-color: var(--tabs-item-color)!important;
            }
        }
    }

    & > li:hover {
        background-color: var(--tabs-item-background-hover);
        color: var(--tabs-item-color-hover);
    }

    & > li.active {
        background-color: var(--tabs-item-background-active);
        color: var(--tabs-item-color-active);
    }

    .d-menu {
        left: auto;
        right: 0;
    }
}

.tabs {
    &.tabs-bottom > ul.tabs-list {
        border: none;

        &:not(.expand) > li {
            margin: -1px 0 0 0;
            border-radius: 0 0 var(--tabs-border-radius) var(--tabs-border-radius);
        }
    }
}

.tabs-expand {
    border: none;

    & > ul.tabs-list {
        border: 0;
        //border-bottom: 2px solid var(--border-color);
        flex-direction: row;
        display: flex !important;
        margin-top: 0;
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 0 0 0 0;

        & > li {
            border-bottom-left-radius: 0;
            border-bottom-right-radius: 0;
            margin-bottom: -1px;
            
            &:last-child {
                margin-bottom: -1px;
            }

            &.active {
                border-bottom: none;
                background-color: var(--tabs-item-background-active);
                color: var(--tabs-item-color-active);
                &::before {
                    display: block;
                    position: absolute;
                    content: '';
                    background-color: var(--tabs-item-marker);
                    height: var(--tabs-item-marker-height);
                    width: 100%;
                    z-index: 1;
                    bottom: 0;
                }
            }
        }

        .d-menu {
            position: absolute;
            width: auto;
        }
    }

    &.tabs-bottom {
        & > ul.tabs-list {
            border: none;
            //border-top: 1px solid var(--border-color);

            & > li {
                border: none;
                //border-top: 1px solid var(--border-color);

                &.active {
                    //border: 1px solid var(--border-color);
                    border-top: none;
                    &::before {
                        bottom: auto;
                        top: 0;
                    }
                }
            }
        }
    }

    .hamburger, .expand-title {
        display: none;
    }

    &:not(.tabs-bottom) {
        ul {
            &.tabs-text, &.tabs-pills, &.tabs-group {
                border-bottom: none;
            }
        }

        
        ul.tabs-text {
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 0;
            
            & > li {
                display: flex;
                align-items: flex-end;
                border: none;
                margin-bottom: 0;

                a {
                    line-height: 2em;

                    .icon {
                        display: none;
                    }
                }
                
                @media (hover: hover) {
                    &:hover {
                        background: @transparent;
                    }
                }
                
                @media (hover: none) {
                    &:hover {
                        background: @transparent;
                    }
                }

                &.active {
                    background-color: transparent;
                    font-size: 2rem;
                    margin-bottom: -2px;
                }

                & > a {
                    height: 100%;
                    padding: 0.5rem .5rem 0;
                    align-items: flex-end;
                }

                &:not(.active) {
                    a {
                        padding-bottom: 10px;
                    }
                }
            }
        }

        ul.tabs-group {
            justify-content: space-between;
            border-collapse: collapse;

            & > li {
                border: 1px solid var(--border-color);
                width: 100%;
                border-radius: 0;
                overflow: hidden;
                
                a {
                    justify-content: center;
                }
                
                &.active {
                    background: var(--tabs-item-background-active);
                    color: var(--tabs-item-color-active);
                    font-weight: 500;

                    &::before {
                        content: "";
                        width: 4px;
                        height: 4px;
                        aspect-ratio: 1/1;
                        background-color: var(--tabs-item-marker);
                        position: absolute;
                        top: 50%;
                        transform: translateY(-50%);
                        left: 8px;
                        z-index: 1;
                        border-radius: 50%;
                    }
                }
                
                &:first-child {
                    border-top-left-radius: var(--tabs-border-radius);
                    border-bottom-left-radius: var(--tabs-border-radius);
                }
                
                &:last-child {
                    border-top-right-radius: var(--tabs-border-radius);
                    border-bottom-right-radius: var(--tabs-border-radius);
                }
            }
        }

        ul.tabs-pills {
            & > li {
                border: 1px solid @transparent;
                overflow: hidden;
                border-radius: var(--tabs-border-radius-pills);

                .icon {
                    border-radius: 50%;
                    border: 1px solid var(--border-color);
                    margin-left: -8px;
                    background-color: var(--tabs-item-icon-background);
                    color: var(--tabs-item-icon-color);
                }
                
                &.active {
                    font-weight: 500;
                    border-color: var(--border-color);
                    background: var(--tabs-item-background-active);
                    color: var(--tabs-item-color-active);
                    padding-left: 8px;
                    
                    &::before {
                        content: "";
                        width: 4px;
                        height: 4px;
                        aspect-ratio: 1/1;
                        background-color: var(--tabs-item-marker);
                        position: absolute;
                        top: 50%;
                        transform: translateY(-50%);
                        left: 8px;
                        z-index: 1;
                        border-radius: 50%;
                    }
                }
            }
        }
    }
}

.tabs {
    .tabs-text { 
        .active::before {
            display: none!important;
        }
    }

    .tabs-list:not(.tabs-group) {
        &.align-left {
            justify-content: flex-start;
        }
        &.align-center {
            justify-content: center;
        }
        &.align-right {
            justify-content: flex-end;
        }
    }
}

each(@colors, {
    .tabs-@{value} {
        --tabs-item-marker: @@value; 
    }
})